package c_000;

import java.util.concurrent.TimeUnit;

public class T02_WhatIsThread {

    private static class T1 extends Thread {
        @Override
        public void run() {
            for(int i = 0; i < 10; i++){
                try {
                    TimeUnit.MICROSECONDS.sleep(1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("T1");
            }
        }
    }

    public static void main(String[] args) {
        //两个执行结果不一样，run()方法执行只有主线程执行所以先调用完run()再往下执行;
        //start()方法执行时会新开一个线程执行任务,从而产生交替运行的结果
//        new T1().run();
        new T1().start();
        for(int i = 0; i < 10; i++){
            try {
                TimeUnit.MICROSECONDS.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("main");
        }
    }
}
